package com.cjh.consumer;

import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

@Component
public class FanoutCustomer {
    @RabbitListener(bindings = @QueueBinding( //绑定队表和交换机
            value = @Queue("fanout_queue1"),//绑定队列
            exchange = @Exchange(name = "logs", type = ExchangeTypes.FANOUT)//绑定交换机和声明交换机类型
    ))
    public void receive1(String message) {
        System.out.println("receive1 = " + message);
    }

    @RabbitListener(bindings = @QueueBinding(
            value = @Queue("fanout_queue2"),
            exchange= @Exchange(name = "logs", type = ExchangeTypes.FANOUT)
    ))
    public void receive2(String message) {
        System.out.println("receive2 = " + message);
    }
}